from error_data import ErrorData


class Dictation(object):
    '''单词听写类'''

    @classmethod
    def chinese_to_english(cls, data):
        '''汉译英'''
        sum = len(data)
        error_data = ErrorData.get_error_data()
        for idx, (key, value) in enumerate(data.items()):
            print(f"~ {idx+1}/{sum} 请根据含义拼写单词:>> {value}")
            input_data = input("请输入英文单词:>> ")
            if input_data == "quit()":
                break
            if input_data == key:
                if error_data.get(key):
                    ErrorData.add_correct_data(key)
                pass
            else:
                ErrorData.add_error_data(key, value)
                print(f"回答错误({ErrorData.get_error_rate(key)})! 正确答案为 -->> {value}: {key} <<-- ")
            print("")

    def english_to_chinese(self):
        '''英译汉'''
        pass

    def sounds_to_english(self):
        '''根据发音进行拼写'''
        pass